//
//  ZWInformationViewController.m
//  wan
//
//  Created by apple on 16/1/24.
//  Copyright © 2016年 MyCompany. All rights reserved.
//

#import "ZWInformationViewController.h"
#import "UIBarButtonItem+CH.h"

@interface ZWInformationViewController () <UITableViewDelegate, UITableViewDataSource>

@end

@implementation ZWInformationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor colorWithRed:248.0/255 green:248.0/255 blue:248.0/255 alpha:1];
    
    //设置导航栏
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithIcon:@"返回" target:self action:@selector(returnClick)];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"顶部"] forBarMetrics:UIBarMetricsDefault];
    self.navigationItem.title = @"基本信息";
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor colorWithWhite:0.1 alpha:1.0], NSFontAttributeName:[UIFont boldSystemFontOfSize:15]};
    
    //设置tableview
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
}

- (void)returnClick
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    if (section == 0) {
        return 1;
    } else {
        return 4;
    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    
    if (indexPath.section == 0) {
        cell.textLabel.text = @"更换头像";
        UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"头像"]];
        image.frame = CGRectMake(300, 11, 40, 40);
        cell.accessoryView = image;
    } else {
        if (indexPath.row == 0 ) {
            cell.textLabel.text = @"昵称";
            UITextField *nameText = [[UITextField alloc] initWithFrame:CGRectMake(100, 5, 40, 30)];
            nameText.userInteractionEnabled = NO;
            nameText.placeholder = @"AMY";
            cell.accessoryView = nameText;
        } else if (indexPath.row == 1) {
            cell.textLabel.text = @"性别";
            UITextField *genderText = [[UITextField alloc] initWithFrame:CGRectMake(100, 5, 20, 30)];
            genderText.userInteractionEnabled = NO;
            genderText.placeholder = @"女";
            cell.accessoryView = genderText;
        } else if (indexPath.row == 2) {
            cell.textLabel.text = @"生日";
            UITextField *dateText = [[UITextField alloc] initWithFrame:CGRectMake(100, 5, 105, 30)];
            dateText.userInteractionEnabled = NO;
            dateText.placeholder = @"输入生日信息";
            cell.accessoryView = dateText;
        } else {
            cell.textLabel.text = @"星座";
            UITextField *consText = [[UITextField alloc] initWithFrame:CGRectMake(100, 5, 35, 30)];
            consText.userInteractionEnabled = NO;
            consText.placeholder = @"双子";
            cell.accessoryView = consText;
        }
            
    }
    
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return 61;
    } else {
        return 40;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 10;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}

@end
